﻿using CleanArchitecture.Infrastructure.Entities.SystemModules;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;

namespace CleanArchitecture.Infrastructure.DataMapping.SystemModules
{
    /// <summary>
    /// Represents a permission record mapping configuration
    /// </summary>
    public partial class PermissionRecordMap : NowaEntityTypeConfiguration<SystemModule>
    {
        #region Methods

        /// <summary>
        /// Configures the entity
        /// </summary>
        /// <param name="builder">The builder to be used to configure the entity</param>
        public override void Configure(EntityTypeBuilder<SystemModule> builder)
        {
            builder.ToTable("sys_module");
            builder.HasKey(record => record.Id);

            builder.Property(record => record.ModuleName).HasMaxLength(255).IsRequired();
            builder.Property(record => record.DisplayName).HasMaxLength(255);
            builder.Property(record => record.ModuleType).IsRequired();
            builder.Property(record => record.ParentId).IsRequired();
            builder.Property(record => record.IconText).HasMaxLength(255);
            builder.Property(record => record.IconCssClass).HasMaxLength(255);
            builder.Property(record => record.UrlRoute).HasMaxLength(500);
            builder.Property(record => record.DisplayOrder).IsRequired();
            builder.Property(record => record.CreatedOnTimeUtc).IsRequired();
            builder.Property(record => record.OpenOnNewWindow).IsRequired();
            builder.Property(record => record.ModuleAssignedButtonIds).HasMaxLength(500);

            builder.Ignore(record => record.ModuleAssignedButtons);
            
            base.Configure(builder);
        }

        #endregion
    }
}
